package com.huaxin.device.models;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.huaxin.hxenum.enums.DataType;
import com.huaxin.hxenum.enums.Unit;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 指标编码字典表
 */
@Data
@TableName("metric_code_dict")
@Schema(description = "指标编码字典")
public class MetricCodeDict {

    @TableId(value = "id", type = IdType.AUTO)
    @Schema(description = "自增ID")
    private Integer id;

    @TableField(value = "metric_code")
    @Schema(description = "6位指标编码", example = "PWR001")
    private String metricCode;

    @TableField(value = "metric_name")
    @Schema(description = "指标名称", example = "三相电压")
    private String metricName;

    @TableField(value = "category")
    @Schema(description = "大类", example = "Power")
    private String category;

    @TableField(value = "data_type")
    @Schema(description = "数据类型：number/string", example = "number")
    private DataType dataType;

    @TableField(value = "unit")
    @Schema(description = "默认单位", example = "V")
    private Unit unit;

    @TableField(value = "description")
    @Schema(description = "详细说明")
    private String description;

    @TableField(value = "alarm_enabled")
    @Schema(description = "是否支持报警：0-否，1-是", example = "1")
    private Boolean alarmEnabled;

    @TableField(value = "lower_limit")
    @Schema(description = "下限报警值", example = "360.0000")
    private BigDecimal lowerLimit;

    @TableField(value = "upper_limit")
    @Schema(description = "上限报警值", example = "420.0000")
    private BigDecimal upperLimit;

    @TableField(value = "is_active")
    @Schema(description = "是否启用", example = "1")
    private Boolean isActive;

    @TableField(value = "created_at")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "创建时间")
    private LocalDateTime createdAt;

    @TableField(value = "updated_at")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(description = "更新时间")
    private LocalDateTime updatedAt;
}